package com.krt.webapp.until;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;

import android.R.integer;
import android.util.Log;

public class HttpPostUtil {
	
	public static String httpReString(String uri) throws Exception{
		HttpPost httpRequest = new HttpPost(uri);
		
//		httpRequest.setEntity(new StringEntity(jsonObject.toString()));
		
		HttpClient client = new DefaultHttpClient();
		// ����ʱ
        client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000);
        // ��ȡ��ʱ
        client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000);

	    //ȡ��HTTP response  
	    HttpResponse httpResponse= client.execute(httpRequest);    
	    //��״̬��Ϊ200 ok   
	    int recode = httpResponse.getStatusLine().getStatusCode();
	    Log.w("debug", "recode=" + Integer.toString(recode));
	    if(recode==200)
	    {  
	    	//ȡ����Ӧ�ִ�  
	    	String strResult=EntityUtils.toString(httpResponse.getEntity());
	    	Log.w("debug", "strResult=" + strResult);
	    	return strResult;
	    }else 
	    {
			return recode+"";
		}
	}

}
